package com.ruoyi.shop.idleComm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shop.idleComm.domain.IdleComment;
import com.ruoyi.shop.idleComm.service.IIdleCommentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 闲置评论Controller
 * 
 * @author yjy
 * @date 2025-06-10
 */
@RestController
@RequestMapping("/idleComm/idleComm")
public class IdleCommentController extends BaseController
{
    @Autowired
    private IIdleCommentService idleCommentService;

    /**
     * 查询闲置评论列表
     */
    @PreAuthorize("@ss.hasPermi('idleComm:idleComm:list')")
    @GetMapping("/list")
    public TableDataInfo list(IdleComment idleComment)
    {
        startPage();
        List<IdleComment> list = idleCommentService.selectIdleCommentList(idleComment);
        return getDataTable(list);
    }

    /**
     * 导出闲置评论列表
     */
    @PreAuthorize("@ss.hasPermi('idleComm:idleComm:export')")
    @Log(title = "闲置评论", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IdleComment idleComment)
    {
        List<IdleComment> list = idleCommentService.selectIdleCommentList(idleComment);
        ExcelUtil<IdleComment> util = new ExcelUtil<IdleComment>(IdleComment.class);
        util.exportExcel(response, list, "闲置评论数据");
    }

    /**
     * 获取闲置评论详细信息
     */
    @PreAuthorize("@ss.hasPermi('idleComm:idleComm:query')")
    @GetMapping(value = "/{commentId}")
    public AjaxResult getInfo(@PathVariable("commentId") Long commentId)
    {
        return success(idleCommentService.selectIdleCommentByCommentId(commentId));
    }

    /**
     * 新增闲置评论
     */
    @PreAuthorize("@ss.hasPermi('idleComm:idleComm:add')")
    @Log(title = "闲置评论", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IdleComment idleComment)
    {
        return toAjax(idleCommentService.insertIdleComment(idleComment));
    }

    /**
     * 修改闲置评论
     */
    @PreAuthorize("@ss.hasPermi('idleComm:idleComm:edit')")
    @Log(title = "闲置评论", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IdleComment idleComment)
    {
        return toAjax(idleCommentService.updateIdleComment(idleComment));
    }

    /**
     * 删除闲置评论
     */
    @PreAuthorize("@ss.hasPermi('idleComm:idleComm:remove')")
    @Log(title = "闲置评论", businessType = BusinessType.DELETE)
	@DeleteMapping("/{commentIds}")
    public AjaxResult remove(@PathVariable Long[] commentIds)
    {
        return toAjax(idleCommentService.deleteIdleCommentByCommentIds(commentIds));
    }
}
